const STS = require('ali-oss').Wrapper.STS
const config = require('../../config').oss
const sts = new STS(config)

Parse.Cloud.define('getUploadImageAuth', async (req, res) => {
  let result = null
  try {
    result = await sts.assumeRole('acs:ram::1955506213263945:role/aliyunosstokengeneratorrole', null, 900)
    console.log(result)
    result.credentials.bucket = 'wxlai'
    result.credentials.region = 'oss-cn-shenzhen'
    result.credentials.domain = 'http://oss.wxlai.com'
    res.success(result.credentials)
  } catch (err) {
    return res.error(err)
  }
})

